Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Sep 8, 2025

This PR uses the sys_signame array present on many UNIX-like systems to derive a better description for values of type ExitStatus and ExitTest.Condition. (On Linux, the equivalent sigabbrev_np() is used. Windows and WASI don't have an equivalent API.)

Before:

let s = ExitStatus.signal(SIGABRT)
print(s) // ".signal(12345)"

After:

let s = ExitStatus.signal(SIGABRT)
print(s) // ".signal(SIGABRT)"

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR uses the `sys_signame` array present on many UNIX-like systems to derive
a better description for values of type `ExitStatus` and `ExitTest.Condition`.
(On Linux, the equivalent `sigabbrev_np()` is used. Windows and WASI don't have
an equivalent API.)
@grynspan grynspan added this to the Swift 6.x (main) milestone Sep 8, 2025
@grynspan grynspan self-assigned this Sep 8, 2025
@grynspan grynspan added enhancement New feature or request linux 🐧 Linux support (all distros) darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support exit-tests ☠️ Work related to exit tests android 🤖 Android support freebsd 😈 FreeBSD support command-line experience ⌨️ enhancements to the command line interface openbsd 🐡 OpenBSD support labels Sep 8, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Sep 8, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Sep 8, 2025

@finagolfin and @3405691582 Could you smoke-test this on Android/OpenBSD please? Thanks!

@grynspan
Copy link
Contributor Author

grynspan commented Sep 8, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Sep 8, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Sep 8, 2025

@swift-ci test

@grynspan grynspan merged commit 03ec484 into main Sep 8, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/improve-exitstatus-desc branch September 8, 2025 21:53
@3405691582
Copy link
Member

(FWIW, the toolchain successfully built after merge on OpenBSD.)

@finagolfin
Copy link
Member

Building this Testing repo natively on Android after this pull worked fine, but I could not build the tests with the following error:

/data/data/com.termux/files/home/swift-testing/Tests/TestingTests/AttachmentTests.swift:58:9: error: deinit of non-copyable type not visible in the current module
 56 |   @Test func moveOnlyDescription() {
 57 |     let attachableValue = MyAttachable(string: "<!doctype html>")
 58 |     let attachment = Attachment(attachableValue, named: "AttachmentTests.saveValue.html")
    |         `- error: deinit of non-copyable type not visible in the current module
 59 |     #expect(attachment.description.contains(#""\#(attachment.preferredName)""#))
 60 |     #expect(attachment.description.contains("'MyAttachable'"))

macro expansion @Test:40:32: error: global variable must be a compile-time constant to use @_section attribute
`- /data/data/com.termux/files/home/swift-testing/Tests/TestingTests/AttachmentTests.swift:47:4: note: expanded code originates here
 41 | @Suite("Attachment Tests")
 42 | struct AttachmentTests {
 43 |   @Test func saveValue() {
    |   `- note: in expansion of macro 'Test' on instance method 'saveValue()' here
 44 |     let attachableValue = MyAttachable(string: "<!doctype html>")
 45 |     let attachment = Attachment(attachableValue, named: "AttachmentTests.saveValue.html")
 46 |     Attachment.record(attachment)
 47 |   }
    +--- macro expansion @Test -----------------------------------------
    |38 | #endif
    |39 | @available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.")
    |40 | private nonisolated static let $s12TestingTests010AttachmentB0V9saveValue4TestfMp_33testContentRecord6e232f07b7901dbafMu_: Testing.__TestContentRecord = (
    |   |                                `- error: global variable must be a compile-time constant to use @_section attribute
    |41 |   0x74657374, /* 'test' */
    |42 |   0,
    +-------------------------------------------------------------------
 48 | 
 49 |   @Test func description() {

Does compiling Testing trunk currently require a recent trunk snapshot toolchain? I'm building it with an older June 17 trunk snapshot toolchain that I natively built on Android too, so I'll need to build one of the latest trunk snapshot toolchains first if so.

Anyway, the exit tests are disabled on Android, so this test won't be run there anyway.

@grynspan
Copy link
Contributor Author

@finagolfin That sounds like swiftlang/swift#84184. Looks like a bug in 6.2 with move-only types, but I don't have more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android 🤖 Android support command-line experience ⌨️ enhancements to the command line interface darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support enhancement New feature or request exit-tests ☠️ Work related to exit tests freebsd 😈 FreeBSD support linux 🐧 Linux support (all distros) openbsd 🐡 OpenBSD support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants